﻿<cfsilent>
	<cfscript>

		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");

		response = structNew();
		structInsert(response, "success", false, true);

		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");

		taskPeriod = event.getArg("TP");
		
		writeLog( text=taskId);

		transaction {
			
			/* 载入教学任务 */
			sql = "SELECT 1 FROM t_new_examtask where task_id = :taskId ";
			
			queryObj = new Query(datasource=application.dnsMaster);
			
			queryObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
			
			rs_task = queryObj.execute( sql=sql ).getResult();
			
			/* 修改教学班周次及周学时 */
			switch(taskType){
				case 'P':
					if( rs_task.recordCount ){
						sql = "UPDATE t_new_examtask a 
							SET a.date_exam = :dateExam,
								a.is_arranged = '2'   
							WHERE a.task_id = :taskId ";
					}else{
						sql = "INSERT INTO t_new_examtask(task_id,date_exam)values(
								:taskId, :dateExam 
						) ";	
					}
					break;
				/*case 'C':
					sql = "UPDATE t_common_task a 
							SET a.task_week = :TaskWeek ,
                 				a.task_period = :TaskPeriod 
							WHERE a.tsk_id = :taskId ";
					break;
				case 'R':
					sql = "UPDATE t_reopen_task a 
							SET a.task_week = :TaskWeek ,
                 				a.task_period = :TaskPeriod  
							WHERE a.tsk_id = :taskId ";
					break;
				case 'T':
					sql = "UPDATE t_sport_task a 
							SET a.task_week = :TaskWeek ,
                 				a.task_period = :TaskPeriod 
							WHERE a.tsk_id = :taskId ";
					break;8*/
			}
			
			updateObj = new Query(datasource=application.dnsMaster);
			updateObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
			updateObj.addParam(name="dateExam", value=taskPeriod, cfsqltype="cf_sql_char");
			updateObj.execute(sql=sql);
	
			
			structInsert(response, "success", true, true);
			
		}

	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>